package WaiBao;

import java.util.Arrays;

public class WuYuNing {
    public static void main(String[] args) {
        String[] name = {"李大虎", "肖仁贵(体育委员)", "小李(学习委员)", "牛接(文艺委员)", "韩塘", "订方药", "上进", "爱贝拉", "夏洛特", "刘备", "关羽", "张飞",
                "潘峰", "李大华", "小黑", "何以笙", "萧默", "吕布", "典韦", "东方要", "李冰冰", "白雪", "张小红", "倪大红", "成龙", "庾澄庆", "汪峰", "许巍",
                "林允", "武宇宁(班长)"};//考生本人: 武宇宁(班长) 学号：210813021131
        int[] age = {20, 19, 18, 20, 19, 20, 19, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 18, 20};//最后一位：考生年龄:20

        double[] haha1 = {87, 72, 81, 90, 79, 69, 78, 89, 80, 80, 91, 87, 85, 89, 65, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 94, 74, 88, 95};
        double[] haha2 = {74, 88, 79, 96, 74, 77, 78, 69, 90, 70, 90, 77, 66, 95, 65, 65, 76, 99, 66, 98, 72, 71, 95, 86, 75, 88, 84, 64, 80, 95};
        double[] haha3 = {81, 76, 84, 84, 77, 66, 78, 69, 80, 80, 93, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 71, 89, 96};


        double count1;//代表每个学生的总分
        double count2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            count1 = haha1[i] + haha2[i] + haha3[i];
//            count2 = (count1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + count1);
//            System.out.println(name[i] + "的平均分为:" + count2);
//        }



//        double heihei = 0, kele = 0;
//        double[] cunfang = new double[30];
//        for (int i = 0; i < 30; i++) {
//            heihei = haha1[i] + haha2[i] + haha3[i];
//            kele = (heihei * 1.0) / 3;
//            cunfang[i] = kele;
//        }
//
//        for (int i = 0; i < cunfang.length - 1; i++) {
//            for (int j = 0; j < cunfang.length - i - 1; j++) {
//                if (cunfang[j] < cunfang[j + 1]) {
//                    double tep = cunfang[j];
//                    cunfang[j] = cunfang[j + 1];
//                    cunfang[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(cunfang[i]);
//        }


        double xuebi1 = 0, xuebi2 = 0, xuebi3 = 0;//计算每门课的平均分
        double guoli1 = 0, guoli2 = 0,guoli3 = 0;//计算每门课标准差
        double laohu1 = 0, laohu2 = 0, laohu3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <haha1.length; i++) {
            he += haha1[i];
        }
        xuebi1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" + xuebi1);
        double Sum = 0;
        for (int i = 0; i < haha2.length; i++) {
            Sum += haha2[i];
        }
        xuebi2 = (Sum * 1.0) / 30;
        System.out.println("物理化学的班级平均分为:" + xuebi2);
        double sum = 0;
        for (int i = 0; i < haha3.length; i++) {
            sum += haha3[i];
        }
        xuebi3 = (sum * 1.0) / 30;
        System.out.println("电子与电工技术的班级平均分为:" + xuebi3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < haha1.length; i++) {
            c1 += (haha1[i] - xuebi1) * (haha1[i] - xuebi1);
        }
        guoli1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + guoli1);
        for (int i = 0; i < haha2.length; i++) {
            c2 += (haha2[i] - xuebi2) * (haha2[i] - xuebi2);
        }
        guoli2 = Math.sqrt(c2*1.0/30);
        System.out.println("物理化学的班级标准差为:" + guoli2);

        for (int i = 0; i < haha3.length; i++) {
            c3 += (haha3[i] - xuebi3) * (haha3[i] - xuebi3);
        }
        guoli3 = Math.sqrt(c3*1.0/30);
        System.out.println("电子与电工技术的班级标准差为:" + guoli3);
////
//
//
//        Arrays.sort(haha1);
//        Arrays.sort(haha2);
//        Arrays.sort(haha3);
//        laohu1 = (haha1[14] + haha2[15]) * 1.0 / 2;
//        laohu2 = (haha2[14] + haha2[15]) * 1.0 / 2;
//        laohu3 = (haha3[14] + haha3[15]) * 1.0 / 2;
//        System.out.println("生物化学的中位数为:" + laohu1);
//        System.out.println("物理化学的中位数为:" + laohu2);
//        System.out.println("电子与电工技术的中位数为:" + laohu3);


    }
}
